<?php
//上传文件时，添加文件信息到数据库
require "../config.php";
$img_url =  $_POST['img_url']; //图片链接
$img_md5 =  $_POST['img_md5']; //图片MD5
$img_sha1 =  $_POST['img_sha1']; //图片sha1
$img_mime =  $_POST['img_mime']; //图片格式
$img_size =  $_POST['img_size']; //图片大小
$album_title = $_POST['album_title']; //图集标题
$shooting_team = $_POST['shooting_team']; //拍摄团队
$shooting_people = $_POST['shooting_people']; //拍摄对象
$conn = new mysqli($MySqlHost, $MySqlUser, $MySqlPwd, $MySqlDatabaseName);
if (!$conn) {
    die("连接失败: " . mysqli_connect_errno());
} else {
    mysqli_query($conn, "set character set 'utf8'"); //读库
    mysqli_query($conn, "set names 'utf8'"); //写库
    if ($img_url != "") {
        $old_num = mysqli_fetch_row(mysqli_query($conn,"SELECT COUNT(*) FROM img_all"))[0];
        mysqli_query($conn, "INSERT INTO img_all (img_md5,img_sha1,img_url,img_mime,img_size,album_title,shooting_team,shooting_people) VALUES('$img_md5','$img_sha1','$img_url','$img_mime','$img_size','$album_title','$shooting_team','$shooting_people')");
        $new_num = mysqli_fetch_row(mysqli_query($conn,"SELECT COUNT(*) FROM img_all"))[0];
        if ($new_num > $old_num){
            echo "OK";
        }else{
            echo "ERROR";
        }
    }
}
